<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
   <!--<script type="text/javascript" src="../Js/jquery.sorted.js"></script>-->
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/script.js" ></script>
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
</head>
<form action="index.html" method="post" id="form">
    <input id="id" name="zmnEntity.id" type="hidden" />
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">学生姓名</td>
        <td><input id="name" type="text" name="zmnEntity.name"/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">性别</td>
        <td><input id="sex" type="text" name="zmnEntity.sex"/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">年龄</td>
        <td><input id="age" type="text" name="zmnEntity.age"/></td>
    </tr>
    <tr>
        <td class="tableleft">班级</td>
        <td>
            <select id="bj" name="zmnEntity.bid" class="form-control">

            </select>
        </td>
    </tr>
    <tr>
        <td class="tableleft">url</td>
        <td><input id="url" type="text" name="zmnEntity.url"/></td>
    </tr>
    <tr>
        <td class="tableleft"></td>
        <td>
            <button type="submit" class="btn btn-primary" type="button" onclick="sub()">保存</button>&nbsp;&nbsp;<button type="button" class="btn btn-success" name="backid" onclick="window.history.back()" id="backid">返回列表</button>
        </td>

    </tr>
</table>
</form>
</body>
</html>
<script>
    $(function () {
        var id = (window.location.href).split('?')[1];
        $.ajax({
            type:"post",
            url:baseUrl+"/zhangmengna!clazz",
            dataType:"json",
            ansyc:false,
            success:function (data) {
                $("#clazz").empty();
                var ht = '';
                $.each(data,function (i,v) {
                    ht = ht + '<option value="'+v.bid+'">'+v.bname+'</option>';
                });
                $("#bj").append(ht);
            }

        });
        if(id != null){
            var did ='';
            $.ajax({
                type:"post",
                url:baseUrl+"/zhangmengna!edit",
                data:{"zmnEntity.id":id},
                dataType:"json",
                ansyc:false,
                success:function (data) {
                    var did ="";
                    if(data != null) {
                        $("#name").val(data.name);
                        $("#sex").val(data.sex);
                        $("#age").val(data.age);
                        $("#url").val(data.url);
                        $("#id").val(data.id);
                        /*$("#bid").val(data.bid);*/

                    }
                    /*  $("#dept").empty();
                      var ht = '';
                      $.each(data.list,function (i,v) {
                          var c ='';
                          if(v.id ==did ){c ='selected=true'};

                          ht = ht + '<option '+c+' value="'+v.id+'">'+v.dname+'</option>';
                      });
                      $("#dept").append(ht);*/
                }

            });
        }


        /*
                $.ajax({
                    type:"post",
                    url:"user/dept",
                    dataType:"json",
                    success:function (data) {

                    }

                });*/
    })
        function sub() {
        $.ajax({
            type:"post",
            url:baseUrl+"/zhangmengna!add",
            data:$("#form").serialize(),//{'name':name，‘age’:age}
            success:function () {
                window.location.href="index.html";
            }

        });
    }

</script>